/**
 * @version 1.0.0
 * @author fxg1997
*/
<template>
  <div class="pages_content table">
    <el-container>
      <el-header>
        <breaDcrumb />
      </el-header>
      <div class="tabtop">
        <div v-for="item in navList" :key="item.id" @click="chooseNav(item.id)">
          <div :class="currenindex == item.id ? 'active' : 'text'">{{ item.value }}</div>
        </div>
      </div>
      <el-main style="display: flex">
        <div>
          <div class="header_right" @click="showCardNav = !showCardNav">
            <div class="title">搜索</div>
            <div>
              <div :class="{ 'arrowTransform': !showCardNav, 'arrowTransformReturn': showCardNav}">
                <i style="margin-right: 5px" class="el-icon-arrow-down"></i>
              </div>
            </div>
          </div>
          <div v-show="showCardNav" class="hr"></div>
          <el-collapse-transition>
            <div v-show="showCardNav">
              <div class="search">
                <span style="display: inline-block;margin-bottom: 10px;">
                  <span style="margin-right: 12px">财务编码</span>
                  <el-input v-model="tableParam.financialCode" style="width: 240px" clearable placeholder="请输入" />
                </span>
                <span style="margin-left: 24px">
                  <span style="margin-right: 12px">工程名称</span>
                  <el-input v-model="tableParam.name" style="width: 180px; min-width: 150px; max-width: 220px" clearable placeholder="请输入" @keyup.enter.native="gettableData()" />
                </span>
                <el-button icon="el-icon-search" size="medium" class="bottom_all" @click="(tableParam.page = 1), gettableData()">查 询</el-button>
                <el-button size="medium" class="bottom_all_two" style="margin-left: 12px" @click="init()">重 置</el-button>
              </div>
            </div>
          </el-collapse-transition>
          <div class="hr"></div>
          <!-- <div class="card scroll"> -->
          <div class="card">
            <div v-loading="tableLoading" class="card_info" :style="style">
              <el-table :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ borderRight: 'none' }" border stripe style="width: 100%" :data="tableData" tooltip-effect="dark">
                <template v-for="(item, index2) in table">
                  <el-table-column v-if="item.status" :key="index2" :label="item.label" align="center" :min-width="item.width">
                    <template slot-scope="scope">
                      <div v-if="item.label == '工程调价'">
                        <el-button class="bottom_one" size="mini" @click="open(scope.row,'dialog1')">
                          调价
                        </el-button>
                      </div>
                      <div v-else-if="item.label == '工程维护'">
                        <el-button class="bottom_one" size="mini" @click="open(scope.row,'dialog2')">
                          维护
                        </el-button>
                      </div>
                      <div v-else-if="item.label == '工程设置'">
                        <el-button class="bottom_one" size="mini" @click="open(scope.row,'dialog3')">
                          设置
                        </el-button>
                      </div>
                      <div v-else-if="item.label == '工程调控'">
                        <el-button class="bottom_one" size="mini" @click="open(scope.row,'dialog3', 1)">
                          查看
                        </el-button>
                      </div>
                      <span v-else>{{ scope.row[item.prop] }}</span>
                    </template>
                  </el-table-column>
                </template>
              </el-table>
            </div>
          </div>
        </div>
      </el-main>
      <div class="card_bottom">
        <div class="card_bottom_left">
          <div class="top_page_totle">总共{{ total }}条</div>
          <el-pagination :current-page.sync="tableParam.page" :page-size="tableParam.pageSize" layout="prev, pager, next, jumper" :total="total" @current-change="gettableData()"></el-pagination>
        </div>
        <div>
          <el-button size="mini" icon="el-icon-refresh-right" class="bottom_all_two" @click="gettableData">刷新</el-button>
        </div>
      </div>
    </el-container>
    <diaLog1 :dialog="dialog1" :low="low" @reset="reset"></diaLog1>
    <diaLog2 :dialog="dialog2" :low="low" @reset="reset" @submit="submit"></diaLog2>
    <diaLog3 :readOnly="readOnly" :dialog="dialog3" :low="low" @reset="reset" @submit="submit"></diaLog3>
  </div>
</template>

<script>
import mixin from "@/mixins/ICPSmixin.js";
import { queryPage } from "@/api/internetSales/engineeringControl.js";
// import { getDicsType } from "@/api/common.js";
// import { getUserInfo } from "@/utils/auth"
const diaLog1 = () => import("./dialog/engineeringControl1")
const diaLog2 = () => import("./dialog/engineeringControl2")
const diaLog3 = () => import("./dialog/engineeringControl3")
let table1 = [
  { label: "工程编号", width: "120", prop: "code", status: true },
  { label: "工程名称", width: "120", prop: "name", status: true },
  { label: "财务编码", width: "auto", prop: "financialCode", status: true },
  { label: "建委合同号", width: "120", prop: "ccContractNo", status: true },
  { label: "合同号", width: "120", prop: "contractNo", status: true },
  { label: "合同单位", width: "120", prop: "roadwork", status: true },
  { label: "工程调价", width: "120", prop: "", status: true },
  { label: "工程维护", width: "120", prop: "", status: true },
  { label: "工程设置", width: "120", prop: "", status: true },
], table2 = [
  { label: "财务编码", width: "auto", prop: "financialCode", status: true },
  { label: "建委合同号", width: "120", prop: "ccContractNo", status: true },
  { label: "财务编码", width: "120", prop: "financialCode", status: true },
  { label: "合同号", width: "120", prop: "contractNo", status: true },
  { label: "工程编号", width: "120", prop: "code", status: true },
  { label: "工程名称", width: "120", prop: "name", status: true },
  { label: "合同单位", width: "120", prop: "roadwork", status: true },
  { label: "工程调价", width: "120", prop: "", status: true },
  { label: "工程维护", width: "120", prop: "", status: true },
  { label: "工程调控", width: "120", prop: "", status: true },
]
export default {
  components: {
    diaLog1,
    diaLog2,
    diaLog3
  },
  mixins: [mixin],
  data() {
    return {
      navList: [
        { id: 1, value: '供应中' },
        { id: 2, value: '供应完成' }
      ],
      currenindex: 1,
      /*表格增删改查及下载接口*/
      queryPage: queryPage,
      /*表格数据*/
      table: [],
      pagesType: 0,
      dialog1: false,
      dialog2: false,
      dialog3: false,
      readOnly: false,
      low: {}
    };
  },
  watch: {
    currenindex: {
      handler() {
        this.tableParam = { ...this.tableParam, financialCode: "", isAssess: 5 };
        this.tableParam.status = this.currenindex
        this.tableParam.pageSize = 10
        this.init();
        if (this.currenindex == 1) {
          this.table = table1
        } else {
          this.table = table2
        }
      },
      deep: false,
      immediate: true,
    }
  },
  methods: {
    chooseNav(index) {
      this.currenindex = index
    },
    open(low, key, type) {
      this.low = low;
      this[key] = true;
      if (type) {
        this.readOnly = true;
        return
      }
      this.readOnly = false;
    },
    reset(key) {
      this[key] = false;
    },
    submit(key) {
      this[key] = false;
    },
    /*重置数据,此方法必须存在，并且方发只重置条件*/
    init() {
      this.tableParam.financialCode = "";
      this.tableParam.name = "";
      this.gettableData();
    },
    pagessubmitFromDate() {
      let _this = this;
      _this.$refs.reffromDate.validate((valid) => {
        if (valid) {
          _this.submitFromDate();
        } else {
          return false;
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.el-input,
.el-select {
  width: 240px;
}
.tabtop {
  width: 381px;
}
</style>
